
	package ioliu;

	import java.io.*;
	import java.util.ArrayList;
	import java.util.Collections;
	import java.util.HashMap;
	import java.util.Random;

import javax.sound.sampled.AudioFormat.Encoding;

	public class readfile {
		public static void main(String[] args) throws IOException {
			
			BufferedReader br = new BufferedReader(
					new InputStreamReader(
					new FileInputStream("C:\\Users\\Administrator\\Desktop\\names.txt"),"gbk"));
			HashMap<String, Student> hm = new HashMap<String, Student>();
			ArrayList<String> al = new ArrayList<String>();
			String str;
			while((str = br.readLine())!=null) {
				
				String[] arr1 = str.split(" ");
				String[] arr2 = arr1[1].split("-");
				Student stu = new Student();
				stu.id = Integer.valueOf(arr1[0]);
				stu.name = arr2[0];
				stu.sex = arr2[1];
				stu.age = Integer.valueOf(arr2[2]);
				hm.put(stu.name,stu);
				al.add(stu.name);
			}
			Random rd = new Random();
			Student stu = hm.get(al.get(rd.nextInt(al.size())));
			System.out.println(stu.id+"-"+stu.name+"-"+stu.sex+"-"+stu.age);
		}
		
		
	}
	class Student{
		int id;
		String name;
		String sex;
		int age;
		
	}

